package com.ct.controller.shops;


import com.ct.application.commons.vo.StatusRequest;
import com.ct.application.shops.model.po.ShopsCategoryAddPO;
import com.ct.application.shops.model.po.ShopsCategoryQueryPO;
import com.ct.application.shops.model.po.ShopsCategoryUpdatePO;
import com.ct.application.shops.model.vo.ShopsCategoryVO;
import com.ct.application.shops.service.ShopsCategoryService;
import com.ct.commons.BaseController;
import com.ct.commons.annotation.ApiLog;
import com.ct.commons.annotation.HasAdmin;
import com.ct.commons.annotation.PermissionApi;
import com.ct.commons.aspect.limiter.AccessIpLimiter;
import com.ct.repository.commons.PageUtils;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 管理后台-门店分类
 *
 * @author system
 * @since 2024-03-05
 */
@RestController
@PermissionApi(title = "门店分类模块",path="/api/v1/shopsCategory",code = "G1000",sorted = 2)
public class ShopsCategoryController extends BaseController {


    @Resource
    private ShopsCategoryService shopsCategoryService;



    /**
     * 获取门店分类列表数据
     */
    @PostMapping("/shopsCategory/getShopsCategoryList")
    @PermissionApi(title = "门店分类列表数据",path="/api/v1/shopsCategory/getShopsCategoryList",code = "G1001",sorted = 1)
    public PageUtils<ShopsCategoryVO> getShopsCategoryList(@Valid @RequestBody ShopsCategoryQueryPO queryPO) {
        return shopsCategoryService.getShopsCategoryList(queryPO);
    }


    /**
     * 获取所有门店分类
     */
    @PostMapping("/shopsCategory/getAllShopsCategoryList")
    @PermissionApi(title = "获取所有门店分类",path="/api/v1/shopsCategory/getAllShopsCategoryList",code = "G1002",sorted = 2)
    public List<ShopsCategoryVO> getAllShopsCategoryList() {
        return shopsCategoryService.getAllShopsCategoryList();
    }


    /**
     * 根据id查询分类
     */
    @PostMapping("/shopsCategory/get/{id}")
    @PermissionApi(title = "根据id查询分类",path="/api/v1/shopsCategory/get/{id}",code = "G1003",sorted = 3)
    public ShopsCategoryVO getShopsCategoryById(@PathVariable("id") Long id) {
        return shopsCategoryService.getShopsCategoryById(id);
    }


    /**
     * 新增门店分类
     */
    @PostMapping("/shopsCategory/add")
    @HasAdmin
    @AccessIpLimiter
    @ApiLog("新增门店分类")
    @PermissionApi(title = "新增门店分类",path="/api/v1/shopsCategory/add",code = "G1004",sorted = 4)
    public Boolean add(@Valid @RequestBody ShopsCategoryAddPO po){
        return shopsCategoryService.add(po);
    }



    /**
     * 修改门店分类
     */
    @PostMapping("/shopsCategory/update")
    @HasAdmin
    @AccessIpLimiter
    @ApiLog("修改门店分类")
    @PermissionApi(title = "修改门店分类",path="/api/v1/shopsCategory/update",code = "G1005",sorted = 5)
    public Boolean update(@Valid @RequestBody ShopsCategoryUpdatePO po){
        return shopsCategoryService.update(po);
    }


    /**
     * 删除门店分类
     */
    @PostMapping("/shopsCategory/delete/{id}")
    @HasAdmin
    @AccessIpLimiter
    @ApiLog("删除门店分类")
    @PermissionApi(title = "删除门店分类",path="/api/v1/shopsCategory/delete/{id}",code = "G1006",sorted = 6)
    public Boolean delete(@PathVariable("id") Long id) {
        return shopsCategoryService.delete(id);
    }


    @PostMapping("/shopsCategory/update/status")
    @HasAdmin
    @AccessIpLimiter
    @ApiLog("删除门店分类")
    @PermissionApi(title = "删除门店分类",path="/api/v1/shopsCategory/update/status",code = "G1007",sorted = 7)
    public Boolean updateStatus(@RequestBody StatusRequest statusRequest) {
        return shopsCategoryService.updateStatus(statusRequest);
    }
}

